home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / c_examples / status / status_example.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-20  |  2.1 KB  |  93 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Status Class Example
  3. // 5.19.96 Deryk Robosson
  4.  
  5. //////////////////////////////////////////////////////////////////////////////
  6. // Includes
  7. #include "aframe:include/amigaapp.hpp"
  8. #include "aframe:include/window.hpp"
  9. #include "aframe:include/button.hpp"
  10. #include "aframe:include/rect.hpp"
  11. #include "aframe:include/status.hpp"
  12. #include "aframe:include/reqtools.hpp"
  13.  
  14. //////////////////////////////////////////////////////////////////////////////
  15. // ControlWindow Class Definition
  16.  
  17. class ControlWindow : public AFWindow
  18.  
  19. {
  20. public:
  21.     ControlWindow();
  22.     virtual void OnGadgetUp(LPIntuiMessage imess);
  23.     virtual ULONG WindowFlags();
  24.  
  25.     AFStatus    status;
  26.     AFButton    up;
  27.     AFButton    down;
  28.  
  29.     short       value;
  30. };
  31.  
  32. //////////////////////////////////////////////////////////////////////////////
  33. // ControlWindow Implementation routines
  34.  
  35. ControlWindow::ControlWindow()
  36.     :value(0)
  37. {
  38. }
  39.  
  40. void ControlWindow::OnGadgetUp(LPIntuiMessage imess)
  41. {
  42.     AFReqTools  rt;
  43.  
  44.     switch(((struct Gadget*)imess->IAddress)->GadgetID) {
  45.     case 99:
  46.         rt.EZRequest("Status Gadget Selected","Ok");
  47.         break;
  48.     case 100:
  49.         if(++value>100)
  50.             value=0;
  51.         status.SetStatus(value);
  52.         break;
  53.     case 101:
  54.         if(--value<0)
  55.             value=100;
  56.         status.SetStatus(value);
  57.         break;
  58.     default:
  59.         AFWindow::OnGadgetUp(imess);
  60.         break;
  61.     }
  62. }
  63.  
  64. ULONG ControlWindow::WindowFlags()
  65. {
  66.     return (AFWindow::WindowFlags() | WFLG_GIMMEZEROZERO);
  67. }
  68.  
  69. //////////////////////////////////////////////////////////////////////////////
  70. // MAIN
  71.  
  72. void main()
  73. {
  74.     AFAmigaApp theApp;
  75.     ControlWindow win;
  76.     AFRect rect(10,10,310,110);
  77.  
  78.     win.Create(&theApp,&rect,"AFrame Status Example");
  79.  
  80.     rect.SetRect(0,0,98,30);
  81.     win.status.Create(&win,&rect,99,3,2);
  82.  
  83.     rect.SetRect(100,0,150,30);
  84.     win.up.Create("Increase",&win,&rect,100);
  85.  
  86.     rect.SetRect(152,0,202,30);
  87.     win.down.Create("Decrease",&win,&rect,101);
  88.  
  89.     win.RefreshGadgets();
  90.  
  91.     theApp.RunApp();
  92. }
  93.